package com.whlilong.jxc.ui.provider;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import com.whlilong.jxc.constants.IAppConstants;
import com.whlilong.jxc.sys.CacheImage;
import com.whlilong.jxc.sys.IImageKey;
import com.whlilong.jxc.treemodel.BrandInfoTreeChildren;
import com.whlilong.jxc.treemodel.BrandInfoTreeParent;
import com.whlilong.jxc.treemodel.MerchantTypeTreeChildren;
import com.whlilong.jxc.treemodel.MerchantTypeTreeParent;

public class BrandInfoTreeLabelProvider implements ITableLabelProvider {

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		if(element instanceof BrandInfoTreeParent){
			if(columnIndex == 0){
				return CacheImage.getINSTANCE().getImage(
						IAppConstants.APPLICATION_ID, IImageKey.brandinfo16);
			}
		}
		if(element instanceof BrandInfoTreeChildren){
			if(columnIndex == 0 ){
				return  CacheImage.getINSTANCE().getImage(
						IAppConstants.APPLICATION_ID, IImageKey.childrenarea);
			}
		}
		return null;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		String text = "";
		if(element instanceof BrandInfoTreeParent){
			BrandInfoTreeParent ktp = (BrandInfoTreeParent)element;
			text = columnIndex == 0? ktp.getGoodsbrandname(): "";
		}
		else if(element instanceof BrandInfoTreeChildren){
			BrandInfoTreeChildren ktc = (BrandInfoTreeChildren)element;
				if(columnIndex == 0)
					text = ktc.getGoodsbrand().getGoodsbrandname();
				
			}
			return text.trim();
	}

	@Override
	public void addListener(ILabelProviderListener listener) {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean isLabelProperty(Object element, String property) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void removeListener(ILabelProviderListener listener) {
		// TODO Auto-generated method stub

	}

}
